From 920234259475bbcd1136afeed7e0f3867e860ffb Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Wed, 13 Jul 2016 14:55:48 +0100 Subject: [PATCH] xen/build: Use C99 booleans and switch bool_t to being of type _Bool rather than char. Using bool_t as char causes several subtle problems; first that a bool_t actually has more than two values, and that (bool_t)0x100 actually has the value 0 rather than the expected 1, due to truncation. Making this change reveals two bugs now caught by the compiler. errata_c6_eoi_workaround() actually makes use of bool_t having more than two states, while generic_apic_probe() has a integer in the middle of a compound bool_t assignment (which triggers a [-Werror=parentheses] warning on Debian Jessie). Finally, it turns out that ARM is mixing and matching bool_t and bool, despite their different semantics. This change brings the semantics of bool_t to match bool, but does not alter the current mix. Signed-off-by: Andrew Cooper Acked-by: Julien Grall Acked-by: Tim Deegan --- xen/arch/arm/p2m.c | 1 - xen/arch/arm/platforms/xgene-storm.c | 1 - xen/arch/arm/traps.c | 1 - xen/arch/x86/acpi/cpu_idle.c | 2 +- xen/arch/x86/genapic/probe.c | 3 ++- xen/include/asm-arm/types.h | 4 ---- xen/include/asm-x86/types.h | 4 ---- xen/include/xen/device_tree.h | 1 - xen/include/xen/types.h | 6 ++++++ 9 files changed, 9 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 976f97b9ea..a4bc55a900 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c index 70cb655649..686b19b6f5 100644 --- a/xen/arch/arm/platforms/xgene-storm.c +++ b/xen/arch/arm/platforms/xgene-storm.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 33261222e0..a2eb1da7cd 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -17,7 +17,6 @@ */ #include -#include #include #include #include diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index a21aeeda2d..7e235a3a2a 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -480,7 +480,7 @@ void trace_exit_reason(u32 *irq_traced) */ bool_t errata_c6_eoi_workaround(void) { - static bool_t fix_needed = -1; + static int8_t fix_needed = -1; if ( unlikely(fix_needed == -1) ) { diff --git a/xen/arch/x86/genapic/probe.c b/xen/arch/x86/genapic/probe.c index a5f2a24d15..860201e5cf 100644 --- a/xen/arch/x86/genapic/probe.c +++ b/xen/arch/x86/genapic/probe.c @@ -56,7 +56,8 @@ custom_param("apic", genapic_apic_force); void __init generic_apic_probe(void) { - int i, changed; + bool changed; + int i; record_boot_APIC_mode(); diff --git a/xen/include/asm-arm/types.h b/xen/include/asm-arm/types.h index 09e5455364..71d2e42390 100644 --- a/xen/include/asm-arm/types.h +++ b/xen/include/asm-arm/types.h @@ -62,10 +62,6 @@ typedef unsigned long size_t; #endif typedef signed long ssize_t; -typedef char bool_t; -#define test_and_set_bool(b) xchg(&(b), 1) -#define test_and_clear_bool(b) xchg(&(b), 0) - #endif /* __ASSEMBLY__ */ #endif /* __ARM_TYPES_H__ */ diff --git a/xen/include/asm-x86/types.h b/xen/include/asm-x86/types.h index b82fa58aa0..e75b7445ba 100644 --- a/xen/include/asm-x86/types.h +++ b/xen/include/asm-x86/types.h @@ -41,10 +41,6 @@ typedef unsigned long size_t; #endif typedef signed long ssize_t; -typedef char bool_t; -#define test_and_set_bool(b) xchg(&(b), 1) -#define test_and_clear_bool(b) xchg(&(b), 0) - #endif /* __ASSEMBLY__ */ #endif /* __X86_TYPES_H__ */ diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index d7d1b40e91..3657ac20cd 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #define DEVICE_TREE_MAX_DEPTH 16 diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 8596ded61c..78410decae 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -1,6 +1,8 @@ #ifndef __TYPES_H__ #define __TYPES_H__ +#include + #include #define BITS_TO_LONGS(bits) \ @@ -59,4 +61,8 @@ typedef __u64 __be64; typedef unsigned long uintptr_t; +typedef _Bool bool_t; +#define test_and_set_bool(b) xchg(&(b), true) +#define test_and_clear_bool(b) xchg(&(b), false) + #endif /* __TYPES_H__ */ -- 2.30.2